package com.smartlifev30.network;

import android.text.TextUtils;
import android.widget.Toast;

import com.smartlifev30.R;
import com.smartlifev30.baiwei.App;

/**
 * 网络请求回调
 *
 * @author tys
 * @date 2018/8/29
 */

public abstract class BaseCallBack<Response> extends smartlifev30.com.sdk.api.CallBack<Response> {

    @Override
    protected void onTimeOut(String detailMessage) {
        super.onTimeOut(detailMessage);
        String tips;
        //sdk提示的网络不可用
        if (detailMessage.contains("网络不可用")) {
            tips = App.getInstance().getResources().getString(R.string.net_connect_error);
        } else {
            tips = App.getInstance().getResources().getString(R.string.request_time_out);
        }
        Toast.makeText(App.getInstance(), tips, Toast.LENGTH_SHORT).show();
    }

    @Override
    protected void onFailed(Throwable throwable, int code) {
        super.onFailed(throwable, code);
        Toast.makeText(App.getInstance(), throwable.getMessage() + "code:" + code, Toast.LENGTH_LONG).show();
    }
}
